import moment from "moment/moment";
import {DatePicker, Input, Select} from "antd";
import {ModalView} from "antd-extra";
import ModalCreateOrEditProd from "./modal/ModalCreateOrEditProd";
import FormBase from "../../components/Base/FormBase";
import MaterialElement from "../finance/modal/MaterialElement";
import React from "react";

moment.locale('zh-cn');
const _ = require('lodash');
const {TextArea} = Input;
const {Option} = Select;
const {RangePicker} = DatePicker;
export default class SalesBase extends FormBase {
  constructor(props) {
    super(props);
    this.props = props;
  }

  onCreateOrEditProd = (record, dispatch) => {
    const type = record.prodCode ? "sales/updateSalesProd" : 'sales/createSalesProd';
    const title = record.prodCode ? "编辑商品" : '添加商品';
    const {spLotId, salesOrderCode} = record;
    ModalView.open(ModalCreateOrEditProd, {
      title,
      width: '1280px'
    }, {
      record,
      callback: data => {
        dispatch({
          type,
          payload: {...data, spLotId, salesOrderCode, code: salesOrderCode}
        }).then(res => {
          this.requestReturn(res);
          this.componentDidMount();
        });
      }
    });
  };

  materialTableColumns() {
    return [
      {
        title: '物料名称', dataIndex: 'name', key: 'name', render: (value, record) => {
          const {code, name} = record;
          return <MaterialElement code={code} name={name}></MaterialElement>;
        }
      },

      {title: '物料形态', dataIndex: 'subcategory', key: 'subcategory'},
      {title: '物料规格', dataIndex: 'spec', key: 'spec'},
      {title: '物料类型', dataIndex: 'type', key: 'type'},
      {title: '物料编号', dataIndex: 'number', key: 'number'},
      {title: '供应商', dataIndex: 'vendor', key: 'vendor'},
      {title: '采购公司', dataIndex: 'division', key: 'division'},
      {title: '单价', dataIndex: 'price', key: 'price'},
      {title: '物料数量', dataIndex: 'materialCount', key: 'materialCount'}
  ]
  }

}
